package com.weatherstation.entity;

import com.baomidou.mybatisplus.annotation.*;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import com.fasterxml.jackson.annotation.JsonFormat;

/**
 * 传感器数据实体类
 * 
 * @author WeatherStation Team
 */
@TableName("sensor_data")
@Data
@NoArgsConstructor
@AllArgsConstructor
public class SensorData {

    @TableId(type = IdType.AUTO)
    private Long id;

    /**
     * 温度(°C)
     */
    @TableField("temperature")
    private BigDecimal temperature;

    /**
     * 湿度(%)
     */
    @TableField("humidity")
    private BigDecimal humidity;

    /**
     * 气压(Pa)
     */
    @TableField("pressure")
    private BigDecimal pressure;

    /**
     * 光照强度
     */
    @TableField("light_intensity")
    private Integer lightIntensity;

    /**
     * 创建时间
     */
    @TableField(value = "created_at", fill = FieldFill.INSERT)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createdAt;

    /**
     * 更新时间
     */
    @TableField(value = "updated_at", fill = FieldFill.INSERT_UPDATE)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updatedAt;

    /**
     * 构造函数 - 用于创建新的传感器数据
     */
    public SensorData(BigDecimal temperature, BigDecimal humidity, BigDecimal pressure, Integer lightIntensity) {
        this.temperature = temperature;
        this.humidity = humidity;
        this.pressure = pressure;
        this.lightIntensity = lightIntensity;
    }
}